Imports System.Drawing.Drawing2D

Public Class GradientText

    Private Sub GradientText_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub GradientText_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim grfx As Graphics = e.Graphics
        Dim cx As Integer = Me.Width
        Dim cy As Integer = Me.Height
        Dim strText As String

        strText = "Gradient"
        Dim font As New Font("Times New Roman", 60, FontStyle.Italic)

        Dim sizef As SizeF = grfx.MeasureString(strText, font)
        sizef.Width \= 8
        sizef.Height \= 8

        Dim ptf As New PointF((cx - sizef.Width) / 2, (cy - sizef.Height) / 2)

        Dim rectf As RectangleF = New RectangleF(ptf, sizef)

        Dim lgbrush As New LinearGradientBrush(rectf, Color.White, Color.Black, LinearGradientMode.ForwardDiagonal)
        lgbrush.WrapMode = WrapMode.TileFlipXY
        grfx.Clear(Color.Gray)
        grfx.DrawString(strText, Font, lgbrush, ptf)
    End Sub
End Class